open(BUFF,"chr22_out_ori.tped") or die "no file exists\n";
$i=0;
while(<BUFF>)
{
	chomp($_);
	@a=split(" ",$_);
	$hash{$a[1]}=$i++;
}
open(BUFF,"gunzip -c Combined_impute_results_3_prob_ambi_out.gz|") or die " no file exists\n";
open(WRBUFF,"|gzip >impute_final.gz");
$line=<BUFF>;
while(<BUFF>)
{
	#print "$.\n";
        chomp($_);
        @a=split(" ",$_);
	shift(@a);
	$_=join(" ",@a);
	if(exists($hash{$a[0]}))
	{
		$am[$hash{$a[0]}]=$_;
	}
}
for($i=0;$i<@am;$i++)
{
	if($am[$i] !~ m/\w/)
        {
                die "$i $am[$i]\n";
        }

	print WRBUFF $am[$i]."\n";
}
